import ApiDefine from "@/api/ApiDefine";
import BaseApi from "@/api/BaseApi";
import { DateUtils } from "@/utils/date_util";

export default class BaseRequestApi {
    public static instance(): BaseRequestApi {
        if (this.instanceObj == null) {
            this.instanceObj = new BaseRequestApi();
            // const x: any = { id: -1, parentId: -1, wechatCode: '' };
        }
        return this.instanceObj;
    }

    private static instanceObj: BaseRequestApi;


    initValidDiscount(discountList: any) {
        var list: any = [];
        list = discountList.filter((e: any, index: number, ar: any[]) => {
            //check state
            return this.isValid(e);
        });

        return list;
    }

    isValid(e: any) {
        //校验时间
        if (e.effectiveEndTime !== null) {
            let d: Date = new Date();
            if (DateUtils.str2Date(e.effectiveEndTime).getTime() - d.getTime() >= 0 && e.state == 1) {
                return true;
            }
            return false;
        } else {
            return false;
        }
    }

}